using UnityEngine;
using UnityEngine.UI;

namespace Assets.Scripts.GDK
{
	public class gdk_logLayer : gdk_baseLayer<gdk_logLayer>
	{
		public override bool isMask()
		{
			return false;
		}

		public override void setNode(GameObject _node)
		{
			base.setNode(_node);
			VerticalLayoutGroup verticalLayoutGroup = _node.AddComponent<VerticalLayoutGroup>();
			ContentSizeFitter contentSizeFitter = _node.AddComponent<ContentSizeFitter>();
			contentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
			contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
		}

		public void log(string str, float time)
		{
			int num = 40;
			int num2 = str.Length - 1;
			int num3 = 100;
			while (num2 > num)
			{
				num3--;
				if (num3 < 0)
				{
					return;
				}
				int num4 = (num >= num2) ? num2 : num;
				string str2 = str.Substring(0, num4);
				str = str.Remove(0, num4);
				num2 = str.Length - 1;
				_log(str2, time);
			}
			if (str != string.Empty)
			{
				_log(str, time);
			}
		}

		private void _log(string str, float time)
		{
			Text text = gdk_utils.NewText();
			text.text = str;
			text.fontSize = 20;
			RectTransform component = text.GetComponent<RectTransform>();
			component.sizeDelta = gdk_utils.getSceneSize();
			component.localPosition = new Vector2(0f, 0f);
			GameObject item = text.gameObject;
			gdk_runTime.setTimeOut(delegate
			{
				if (gdk_runTime.isValid(item))
				{
					UnityEngine.Object.Destroy(item, 1f);
				}
				else
				{
					UnityEngine.Debug.Log("item end Destroy");
				}
			}, time, item);
			if (getNode() == null)
			{
				UnityEngine.Debug.Log("禁止在场景onload执行log");
			}
			else
			{
				base.show(component.gameObject);
			}
		}
	}
}
